package com.itheima.reggie.mapper;

import com.itheima.reggie.entity.Report;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ReportMapper {

    @Select("SELECT\n" +
            "category.`name`,\n" +
            "Sum(order_detail.number) AS `value`\n" +
            "FROM\n" +
            "order_detail\n" +
            "INNER JOIN dish ON order_detail.dish_id = dish.id\n" +
            "INNER JOIN category ON dish.category_id = category.id\n" +
            "GROUP BY\n" +
            "category.`name`")
    public List<Report> getOrderReport();
}
